package org.dtrd.config.wechat.entity.bean.officialaccount.template;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.common.PathUtil;
import org.dtrd.config.wechat.config.WechatUtil;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatOaTemplateMsg;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatTemplateMiniProgram;

import java.util.Date;

/**
 * 打卡成功推送消息
 *
 * @author xiao
 * @date 2022/8/7 10:14 PM
 */
@Data
@Slf4j
public class AbnormalSugarMsg extends WechatOaTemplateMsg {

    /**
     * 患者打卡的血糖项目
     */
    private String typeName;
    /**
     * 打卡时间
     */
    private String signinTime;
    /**
     * 血糖值
     */
    private Float sugarValue;
    /**
     * 波动值
     */
    private Float waveValue;

    private String msg;


    public static final class AbnormalSugarMsgBuilder {
        private AbnormalSugarMsg abnormalSugarMsg;

        private AbnormalSugarMsgBuilder() {
            abnormalSugarMsg = new AbnormalSugarMsg();
        }

        public static AbnormalSugarMsgBuilder singleInstance() {
            return new AbnormalSugarMsgBuilder();
        }

        public AbnormalSugarMsgBuilder withMsgTitle(String msgTitle) {
            abnormalSugarMsg.setMsgTitle(msgTitle);
            return this;
        }

        public AbnormalSugarMsgBuilder withUrl(String url) {
            abnormalSugarMsg.setUrl(url);
            return this;
        }

        public AbnormalSugarMsgBuilder withMiniProgram(WechatTemplateMiniProgram miniProgram) {
            abnormalSugarMsg.setMiniProgram(miniProgram);
            return this;
        }

        public AbnormalSugarMsgBuilder withRemark(String remark) {
            abnormalSugarMsg.setRemark(remark);
            return this;
        }

        public AbnormalSugarMsgBuilder withMsgTime(String msgTime) {
            abnormalSugarMsg.setMsgTime(msgTime);
            return this;
        }

        public AbnormalSugarMsgBuilder withReceiverOpenIdArray(String[] receiverOpenIdArray) {
            abnormalSugarMsg.setReceiverOpenIdArray(receiverOpenIdArray);
            return this;
        }

        public AbnormalSugarMsgBuilder withTypeName(String signinName) {
            abnormalSugarMsg.setTypeName(signinName);
            return this;
        }

        public AbnormalSugarMsgBuilder withSugarValue(Float sugarValue) {
            abnormalSugarMsg.setSugarValue(sugarValue);
            return this;
        }

        public AbnormalSugarMsgBuilder withWaveValue(Float waveValue) {
            abnormalSugarMsg.setWaveValue(waveValue);
            return this;
        }

        public AbnormalSugarMsgBuilder withMsg(String msg) {
            abnormalSugarMsg.setMsg(msg);
            return this;
        }

        public AbnormalSugarMsgBuilder withSigninTime(String signinTime) {
            abnormalSugarMsg.setSigninTime(signinTime);
            return this;
        }

        public AbnormalSugarMsg build() {
            return abnormalSugarMsg;
        }


        /**
         * 打卡成功
         *
         * @param timeType 打卡项名称
         * @param signinTime 打卡时间
         * @param patientId
         * @return 您本次血糖打卡情况如下，如有身体不适请及时联系您的医疗团队
         * 打卡项目：患者打卡的血糖项目
         * 打卡时间：2022年6月23日 14:20
         * 血糖值：8.1mmol/L
         * 血糖波动幅度：3.2mmol/L
         * 血糖分析：异常提示（参考异常情况文档）
         * 点击联系您的医师团队
         */
        public AbnormalSugarMsg buildAbnormalSugarMsg(String msgTitle, String timeType, String  signinTime, Integer patientId, Float sugarValue, Float waveValue, String msg, String url, String remark) {

            this.withMsgTitle(msgTitle)
                    .withTypeName(timeType)
                    .withUrl(url)
                    .withSigninTime(signinTime)
                    .withSugarValue(sugarValue)
                    .withWaveValue(waveValue)
                    .withMsg(msg)
                    .withRemark(remark);
            log.info("AbnormalSugarMsgBuilder.buildAbnormalSugarMsg.[signinName={}, signinTime={}, patientId={}", timeType, signinTime, patientId);
            return this.build();
        }
    }
}
